﻿using IterationLife.Educations.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.Educations {
    /// <summary>
    /// 教材数据传输对象扩展
    /// </summary>
    public static class TextBookDtoExtension {
        /// <summary>
        /// 转换为教材实体
        /// </summary>
        /// <param name="dto">教材数据传输对象</param>
        public static TextBook ToEntity( this TextBookDto dto ) {
            if ( dto == null )
                return new TextBook();
            return dto.MapTo( new TextBook( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为教材数据传输对象
        /// </summary>
        /// <param name="entity">教材实体</param>
        public static TextBookDto ToDto(this TextBook entity) {
            if( entity == null )
                return new TextBookDto();
            return entity.MapTo(new TextBookDto());
        }
    }
}
